From: Tim Starling Date: Fri, 21 Jan 2005 14:00:18 +0000 (+0000) Subject: stream timeout option X-Git-Tag: 1.5.0alpha1~876 X-Git-Url: http://git.cyclocoop.org/%28%5B%5E/404?a=commitdiff_plain;h=776287c528433f05c6b55574c166177d8638d951;p=lhc%2Fweb%2Fwiklou.git stream timeout option --- diff --git a/includes/memcached-client.php b/includes/memcached-client.php index 18e64bf932..4ff0da91ce 100644 --- a/includes/memcached-client.php +++ b/includes/memcached-client.php @@ -205,6 +205,22 @@ class memcached */ var $_active; + /** + * Stream timeout in seconds. Applies for example to fread() + * + * @var integer + * @access private + */ + var $_timeout_seconds; + + /** + * Stream timeout in microseconds + * + * @var integer + * @access private + */ + var $_timeout_microseconds; + // }}} // }}} // {{{ methods @@ -231,6 +247,9 @@ class memcached $this->_cache_sock = array(); $this->_host_dead = array(); + + $this->_timeout_seconds = 1; + $this->_timeout_microseconds = 0; } // }}} @@ -606,6 +625,20 @@ class memcached $this->_single_sock = $this->_servers[0]; } + /** + * Sets the timeout for new connections + * + * @param integer $seconds Number of seconds + * @param integer $microseconds Number of microseconds + * + * @access public + */ + function set_timeout ($seconds, $microseconds) + { + $this->_timeout_seconds = $seconds; + $this->_timeout_microseconds = $microseconds; + } + // }}} // }}} // {{{ private methods @@ -654,6 +687,10 @@ class memcached $this->_debugprint( "Error connecting to $host: $errstr\n" ); return false; } + + // Initialise timeout + stream_set_timeout($sock, $this->_timeout_seconds, $this->_timeout_microseconds); + return true; }